<template>
  <div class="app-container">
    <!-- v-permission="['danger:equipmentInfo:read']"
    v-permission="['danger:equipmentInfo:create']"
    v-permission="['danger:equipmentInfo:update']"
    v-permission="['danger:equipmentInfo:delete']" -->
    <!-- 查询和其他操作 -->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="设备名称">
        <el-input
          v-model="listQuery.fequipmentname"
          clearable
          class="filter-item"
          style="width: 200px"
          placeholder="请输入设备名称"
        />
      </el-form-item>
      <el-form-item>
        <el-button
        round size="medium"
          class="filter-item"
          :style="{background:buttonColor.lookup,color:buttonColor.color}"
          icon="el-icon-search"
          @click="handleFilter"
          >查找</el-button
        >
        <el-button
        round size="medium"
          class="filter-item"
          :style="{background:buttonColor.add ,color:buttonColor.color}"
          icon="el-icon-edit"
          @click="handleCreate"
          >添加</el-button
        >
      </el-form-item>
    </el-form>

    <!-- 查询结果 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      stripe
      element-loading-text="正在查询中。。。"
      border
      fit
      highlight-current-row
      :header-cell-style="tableColor"
    >
      <el-table-column
        :index="indexMethod"
        align="center"
        label="序"
        type="index"
      />
      <el-table-column align="center" label="设备编号" prop="fequipmentno" />
      <el-table-column align="center" label="设备名称" prop="fequipmentname" />
      <el-table-column :formatter="formatfclassstno" align="center" label="设备分类" prop="fclassstno" />
      <el-table-column align="center" label="计量单位" prop="funit" />
      <el-table-column align="center" label="品牌" prop="fbrand" />
      <el-table-column align="center" label="型号" prop="fspec" />
      <el-table-column align="center" label="使用年限" prop="fuseyear" />
      <el-table-column align="center" label="设备图片" prop="fimage" />
      <el-table-column :formatter="formatfequipmenttype" align="center" label="设备类型" prop="fequipmenttype" />
      <el-table-column align="center" label="控制面板" prop="fpanel">
        <template slot-scope="scope">
          <el-tag effect="dark" type='danger' v-if="scope.row.fpanel===0">{{ scope.row.fpanel | siteTypeFilter }}</el-tag>
          <el-tag effect="dark" type='danger' v-if="scope.row.fpanel===1">{{ scope.row.fpanel | siteTypeFilter }}</el-tag>
          <p v-else></p>
        </template>
      </el-table-column>
      <el-table-column align="center" label="设备条码" prop="fbarcode" />
      <el-table-column align="center" label="设备报价" prop="fbuyprice" />

      <el-table-column align="center" label="操作" class-name="small-padding" width="130">
        <template slot-scope="scope">
          <el-button
            :style="{background:buttonColor.edit,color:buttonColor.color}"
            round size="small"
            class="button-margin"
            @click="handleUpdate(scope.row)"
            >编辑</el-button
          >
          <el-button
            :style="{background:buttonColor.delete,color:buttonColor.color}"
            round size="small"
            class="button-margin"
            @click="handleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="getList"
    />

    <!-- 添加或修改对话框 -->
    <el-dialog
      width="auto"
      top="0vh"
      :close-on-click-modal="false"
      :title="textMap[dialogStatus]"
      :visible.sync="dialogFormVisible"
      :before-close="handleClose"
    >
      <el-form
        ref="dataForm"
        :rules="rules"
        :model="dataForm"
        status-icon
        label-position="left"
        label-width="auto"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item
              label="设备编号"
              prop="fequipmentno"
            >
            <div style="display:flex;justify-content:flex-end;align-items:center">
              <el-input style="display: inline-block" v-model="dataForm.fequipmentno" @change="limits()"/>
              <i style="display: inline-block;color:#409EFF;margin-left:3px" class="el-icon-search" @click="searchDialog"></i>
            </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="设备名称"
              prop="fequipmentname"
            >
              <el-input :disabled='true' v-model="dataForm.fequipmentname" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="设备分类"
              prop="fclassstno"
            >
              <el-select :disabled='true' filterable clearable v-model="dataForm.fclassstno" class="filter-item" placeholder="请选择设备分类">
                <el-option
                v-for="item in getListfclassstno"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="单位" prop="funit">
              <el-input :disabled='true' v-model="dataForm.funit" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="品牌" prop="fbrand" >
              <el-input :disabled='true' v-model="dataForm.fbrand" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="型号" prop="fspec">
              <el-input :disabled='true' v-model="dataForm.fspec" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="使用年限" prop="fuseyear">
              <el-input :disabled='true' v-model.number="dataForm.fuseyear" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="设备类型"
              prop="fequipmenttype"
            >
              <el-select :disabled='true' filterable clearable v-model="dataForm.fequipmenttype" class="filter-item" placeholder="请选择设备分类">
                <el-option
                v-for="item in getListfequipmenttype"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="控制面板" prop="fpanel">
              <el-select
              :disabled='true'
                v-model="dataForm.fpanel"
                clearable
                filterable
                class="filter-item"
                placeholder="是否有控制面板"
              >
                <el-option
                  v-for="item in siteTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="图片(2M内)" prop="fimage">
              <el-upload
                :disabled='isActive'
                v-model="dataForm.fimage"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload"
                :action="uploadPath"
                :data="formdata2(dataForm.fequipmentno)"
                class="avatar-uploader">
                <img v-if="dataForm.fimage" :src="dataForm.fimage" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon" style="font-size:9px" @click="test()"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设备条码" prop="fbarcode">
              <el-input :disabled='true' v-model="dataForm.fbarcode" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="设备报价"
              prop="fbuyprice"
            >
              <el-input :disabled='true' v-model="dataForm.fbuyprice" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <el-tabs type="border-card">
        <el-tab-pane label="报警字典">
          <div class="app-container">
            <!-- 子表查询和其他操作 -->
            <div class="filter-container">
              <el-button
              round size="medium"
                class="filter-item"
                :style="{background:buttonColor.add ,color:buttonColor.color}"
                icon="el-icon-edit"
                @click="handleUpdate1"
                >添加</el-button
              >
            </div>

            <!-- 子表查询结果 -->
            <el-table
              v-loading="listLoading"
              :data="dataForm.details"
              stripe
              element-loading-text="正在查询中。。。"
              border
              fit
              highlight-current-row
              :header-cell-style="tableColor"
              height="16vh"
            >
              <el-table-column
              width="100"
                align="center"
                label="行号"
                prop="fline"
                type="index"
              />
              <el-table-column
                align="center"
                label="报警编号"
                prop="fdangerno"
              />
              <el-table-column
                align="center"
                label="报警说明"
                prop="fdangername"
              />
              <el-table-column
              :formatter="formatflevelno"
                align="center"
                label="风险等级"
                prop="flevelno"
              />
              <el-table-column
                align="center"
                label="操作"
                class-name="small-padding"
              >
                <template slot-scope="scope">
                  <el-button
                   :style="{background:buttonColor.delete,color:buttonColor.color}"
                    round size="small"
                    class="button-margin"
                    @click="handleDelete1(scope.row)"
                    >删除</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane></el-tabs
      >
      <div slot="footer" class="dialog-footer">
        <el-button :style="{background:buttonColor.cancel,color:buttonColor.colorone}" @click="cancel()">取消</el-button>
        <el-button
          v-if="dialogStatus == 'create'"
          :style="{background:buttonColor.confirm,color:buttonColor.color}"
          @click="createData"
          >确定</el-button
        >
        <el-button v-else :style="{background:buttonColor.confirm,color:buttonColor.color}" @click="updateData">确定</el-button>
      </div>
    </el-dialog>

    <!-- 子表添加或修改对话框 -->
    <el-dialog
      :close-on-click-modal="false"
      :title="textMap[dialogStatus1]"
      :visible.sync="dialogFormVisible1"
      width="auto"
    >
      <el-form
        ref="dataForm1"
        :rules="rules1"
        :model="dataForm1"
        status-icon
        label-position="left"
        label-width="auto"
        style="width: 400px; margin:0 30px"
      >
      <el-form-item label="行号" prop="fline">
          <el-input v-model.number="dataForm1.fline" disabled/>
        </el-form-item>
        <el-form-item label="报警编号" prop="fdangerno">
          <el-input v-model="dataForm1.fdangerno" />
        </el-form-item>
        <el-form-item label="报警说明" prop="fdangername">
          <el-input v-model="dataForm1.fdangername" />
        </el-form-item>
        <el-form-item label="风险等级" prop="flevelno">
          <el-select clearable filterable v-model="dataForm1.flevelno" class="filter-item" placeholder="请选择风险等级">
                <el-option
                v-for="item in getListflevelno"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :style="{background:buttonColor.cancel,color:buttonColor.colorone}" @click="dialogFormVisible1 = false">取消</el-button>
        <el-button :style="{background:buttonColor.confirm,color:buttonColor.color}" @click="addData">确定</el-button>
      </div>
    </el-dialog>
    <!-- 设备搜索弹出框 -->
    <el-dialog
    top="5vh"
      :close-on-click-modal="false"
      title="搜索"
      :visible.sync="searchVisible"
    >
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="设备编号">
        <el-input
          v-model="listQuerySearch.fequipmentno"
          clearable
          class="filter-item"
          style="width: 150px"
          placeholder="请输入设备编号"
        />
      </el-form-item>
      <el-form-item label="设备名称">
        <el-input
          v-model="listQuerySearch.fequipmentname"
          clearable
          class="filter-item"
          style="width: 150px"
          placeholder="请输入设备名称"
        />
      </el-form-item>
       <el-form-item>
        <el-button
        round size="medium"
          class="filter-item"
         :style="{background:buttonColor.lookup,color:buttonColor.color}"
          icon="el-icon-search"
          @click="searchFilter"
          >查找</el-button
        >
      </el-form-item>
    </el-form>

    <!-- 查询结果 -->
    <el-table
      v-loading="listLoadingSearch"
      :data="searchList"
      stripe
      element-loading-text="正在查询中。。。"
      border
      fit
      highlight-current-row
      :header-cell-style="tableColor"
      height="300"
    >
      <el-table-column align="center" label="设备编号" prop="fequipmentno" />
      <el-table-column align="center" label="设备名称" prop="fequipmentname" />
       <el-table-column
                align="center"
                label="选择"
                class-name="small-padding"
              >
                <template slot-scope="scope">
                  <el-button
                  :style="{background:buttonColor.confirm,color:buttonColor.color}"
                    round size="small"
                    class="button-margin"
                    @click="searchData(scope.row)"
                    >确定</el-button
                  >
                </template>
              </el-table-column>
    </el-table>

    <pagination
      v-show="totalSearch > 0"
      :total="totalSearch"
      :page.sync="listQuerySearch.page"
      :limit.sync="listQuerySearch.limit"
      @pagination="getSearchList"
      style="padding:14px 10px !important"
    />
    </el-dialog>
  </div>
</template>

<style>
.button-margin {
  margin: 2px 0px;
}
.el-button + .el-button {
  margin-left: 1px;
}
</style>

<script>
import { listinfo, createinfo, updateinfo, deleteinfo } from "@/api/info";
import { getListArea } from '@/api/area'
import Pagination from "@/components/Pagination";
import {uploadPath} from '@/api/room'
import moment from "moment";
import { tableColor,buttonColor } from "@/filters/index";

const siteTypeMap = {
  0: "否",
  1: "是",
};

export default {
  name: "STsEquipmentInfo",
  components: { Pagination },
  filters: {
    siteTypeFilter(type) {
      return siteTypeMap[type];
    },
  },
  data() {
    return {
      indexs :1,
      uploadPath,
      isActive:true,
      getListfclassstno:null,
      getListfequipmenttype:null,
      searchVisible: false,
      searchList: null,
      getListflevelno: null,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        fequipmentno: undefined,
        fequipmentname: undefined,
        fclassstno: undefined,
        funit: undefined,
        fbrand: undefined,
        fspec: undefined,
        fuseyear: undefined,
        fimage: undefined,
        fequipmenttype: undefined,
        fpanel: undefined,
        fbarcode: undefined,
        fbuyprice: undefined,
        fupddate: undefined,
        foperator: undefined,
        sort: "create_time",
        order: "desc",
      },
      totalSearch: 0,
      listLoadingSearch: true,
      listQuerySearch:{
        page: 1,
        limit: 20,
        fequipmentno: undefined,
        sort: "create_time",
        order: "desc",
      },
      dataForm: {
        fequipmentno: undefined,
        fequipmentname: undefined,
        fclassstno: undefined,
        funit: undefined,
        fbrand: undefined,
        fspec: undefined,
        fuseyear: undefined,
        fimage: undefined,
        fequipmenttype: undefined,
        fpanel: undefined,
        fbarcode: undefined,
        fbuyprice: undefined,
        fupddate: undefined,
        foperator: undefined,
        id: undefined,
        details: [],
      },
      siteTypeList: [
        { value: 1, label: "是" },
        { value: 0, label: "否" },
      ],
      actionsTmp: [],
      listTmp: [],
      dialogFormVisible1: false,
      dialogStatus1: "",
      dataForm1: {
        fline: undefined,
      },

      dialogFormVisible: false,
      dialogStatus: "",
      textMap: {
        update: "编辑",
        create: "创建"
      },
      tableColor: tableColor,
      buttonColor:buttonColor,
      rules: {
        fequipmentno: [{ required: true, message: "设备编号不能为空" }],
        fequipmentname: [{ required: true, message: "设备名称不能为空" }],
        fclassstno: [{ required: true, message: "分类编号不能为空" }],
        funit: [],
        fbrand: [],
        fspec: [],
        fuseyear: [
          {
            type: "number",
            message: "使用年限必须为数字值",
            transform: (value) => Number(value),
          },
        ],
        fimage: [],
        fequipmenttype: [
          { required: true, message: "设备类型不能为空" },
          {
            type: "number",
            message: "设备类型必须为数字值",
            transform: (value) => Number(value),
          },
        ],
        fpanel: [
          { required: true, message: "是否有控制面板不能为空" },
          {
            type: "number",
            message: "是否有控制面板必须为数字值",
            transform: (value) => Number(value),
          },
        ],
        fbarcode: [],
        fbuyprice: [],
        fupddate: [],
        foperator: [],
      },
      rules1: {
        fline: [
          { required: true, message: "行号不能为空" },
          {
            type: "number",
            message: "行号必须为数字值",
            transform: (value) => Number(value),
          },
        ],
        fdangerno: [{ required: true, message: "报警编号不能为空" }],
        fdangername: [{ required: true, message: "报警说明不能为空" }],
        flevelno: [
          { required: true, message: "风险等级编号不能为空" },
          {
            type: "number",
            message: "风险等级编号必须为数字值",
            transform: (value) => Number(value),
          },
        ],
        fupddate: [],
        foperator: [],
      },
    };
  },
  created() {
    this.getList();
    getListArea({flag:7})
      .then(response => {
        this.getListflevelno = response.data.data.list
      })
      .catch(() => {
        this.getListflevelno = []
      })
      getListArea({flag:2})
      .then(response => {
        this.getListfclassstno = response.data.data.list
      })
      .catch(() => {
        this.getListfclassstno = []
      })

      getListArea({flag:1})
      .then(response => {
        this.getListfequipmenttype = response.data.data.list
      })
      .catch(() => {
        this.getListfequipmenttype = []
      })
      this.getSearchList()

  },
  methods: {
    //输入物料编号，上传图片
    limits(){
      if(this.dataForm.fequipmentno !=undefined&&this.dataForm.fequipmentno !='' )
        {
          this.isActive = false;
        }
        else
        {
          this.isActive = true;
        }
    },

  test(){
    if(this.isActive)
    {
      this.$notify.error({
          title: "失败",
          message: '请先输入设备编号',
      });
    }
  },
    // 设备类型
    formatfequipmenttype: function(row, column) {
      if(this.getListfequipmenttype.length>0){
        for (let i = 0; i < this.getListfequipmenttype.length; i++) {
        if (row.fequipmenttype === this.getListfequipmenttype[i].value) {
          return this.getListfequipmenttype[i].label
        }
      }
      return ''
      }else{
        return ''
      }

    },
    // 设备分类
    formatfclassstno: function(row, column) {
       if(this.getListfclassstno.length>0){
         for (let i = 0; i < this.getListfclassstno.length; i++) {
        if (row.fclassstno === this.getListfclassstno[i].value) {
          return this.getListfclassstno[i].label
        }
      }
      return ''
       }else{
         return ''
       }

    },
    // 设备信息列表
    getSearchList(){
      this.listLoadingSearch = true;
      listinfo(this.listQuerySearch)
      .then(response => {
        this.searchList = response.data.data.list
        this.totalSearch = response.data.data.total;
        this.listLoadingSearch = false;
      })
      .catch(() => {
        this.searchList = []
        this.totalSearch = 0;
        this.listLoadingSearch = false;
      })
    },
    // 搜索弹出框
    searchDialog(){
      this.searchVisible=true
      this.isActive = false
    },
    searchData(row){
      this.searchVisible=false
      this.dataForm.fequipmentno=row.fequipmentno
      this.dataForm.fequipmentname=row.fequipmentname
      this.dataForm.fclassstno=row.fclassstno
      this.dataForm.funit=row.funit
      this.dataForm.fbrand=row.fbrand
      this.dataForm.fspec=row.fspec
      this.dataForm.fuseyear=row.fuseyear
      this.dataForm.fequipmenttype=row.fequipmenttype
      this.dataForm.fpanel=row.fpanel
      this.dataForm.fimage=row.fimage
      this.dataForm.fbarcode=row.fbarcode
      this.dataForm.fbuyprice=row.fbuyprice
    },
    formatflevelno: function(row, column) {
      if(this.getListflevelno){
        for (let i = 0; i < this.getListflevelno.length; i++) {
        if (row.flevelno === this.getListflevelno[i].value) {
          return this.getListflevelno[i].label
        }
      }
      return ''
      }else{
      return ''
      }
    },
    datetimeFormat(row, column) {
      const date = row[column.property];
      if (date === undefined || date === null) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
    getList() {
      this.listLoading = true;
      listinfo(this.listQuery)
        .then((response) => {
          this.list = response.data.data.list;
          this.total = response.data.data.total;
          this.listLoading = false;
        })
        .catch(() => {
          this.list = [];
          this.total = 0;
          this.listLoading = false;
        });
    },
    handleFilter() {
      this.listQuery.page = 1;
      this.getList();
    },
    searchFilter(){
      this.listQuerySearch.page=1
      this.getSearchList();
    },
    resetForm() {
      this.dataForm = {
        fequipmentno: undefined,
        fequipmentname: undefined,
        fclassstno: undefined,
        funit: undefined,
        fbrand: undefined,
        fspec: undefined,
        fuseyear: undefined,
        fimage: undefined,
        fequipmenttype: undefined,
        fpanel: undefined,
        fbarcode: undefined,
        fbuyprice: undefined,
        fupddate: undefined,
        foperator: undefined,
        id: undefined,
        details: [],
      };
    },
    handleCreate() {
      this.resetForm();
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    createData() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          this.dataForm.foperator=this.$store.state.user.id
          this.dataForm.fupddate=new Date()
          createinfo(this.dataForm)
            .then((response) => {
              this.list.unshift(response.data.data);
              this.dialogFormVisible = false;
              this.$notify.success({
                title: "成功",
                message: "添加设备资料成功",
              });
              this.indexs = 1;
            })
            .catch((response) => {
              this.$notify.error({
                title: "失败",
                message: response,
              });
            });
        }
      });
    },
    handleUpdate(row) {
      this.listTmp=row
      this.actionsTmp = [];
      row.details.forEach((v) => {
        this.actionsTmp.push(v);
      });

      this.dataForm = Object.assign({}, row);
      this.dialogStatus = "update";
      this.dialogFormVisible = true;
      var end = row.details[row.details.length-1]
      this.indexs = end.fline+1;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    updateData() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          this.dataForm.foperator=this.$store.state.user.id
          this.dataForm.fupddate=new Date()
          updateinfo(this.dataForm, this.$route.query.id)
            .then(() => {
              for (const v of this.list) {
                if (v.feuipmentid === this.dataForm.feuipmentid) {
                  const index = this.list.indexOf(v);
                  this.list.splice(index, 1, this.dataForm);
                  break;
                }
              }
              this.dialogFormVisible = false;
              this.$notify.success({
                title: "成功",
                message: "更新设备资料成功",
              });
            })
            .catch((response) => {
              this.$notify.error({
                title: "失败",
                message: response,
              });
            });
        }
      });
    },
    handleDelete(row) {
      this.$confirm("是否要删除设备资料", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        deleteinfo(row)
          .then((response) => {
            this.$notify.success({
              title: "成功",
              message: "删除设备资料成功",
            });
            const index = this.list.indexOf(row);
            this.list.splice(index, 1);
          })
          .catch((response) => {
            this.$notify.error({
              title: "失败",
              message: response,
            });
          });
      });
    },
    indexMethod(index) {
      index = index + 1;
      return index;
    },

    handleUpdate1() {
      this.dataForm1 = {
        fline:this.indexs,
      };
      this.dialogStatus1 = "create";
      this.dialogFormVisible1 = true;
      this.$nextTick(() => {
        this.$refs["dataForm1"].clearValidate();
      });
    },

    handleDelete1(row) {
      const index = this.dataForm.details.indexOf(row);
      this.dataForm.details.splice(index, 1);
      // this.dataForm.details.pop(row)
    },
    addData() {
      this.$refs["dataForm1"].validate((valid) => {
        this.dataForm1.fline = this.indexs
        if (valid) {
          this.dialogFormVisible1 = false;
          this.dataForm.details.push(this.dataForm1);
          this.indexs++;
        }
      });
    },
    cancel() {
      this.indexs = 1;
      this.dialogFormVisible = false;
      this.list.forEach((v) => {
        if (v.feuipmentid === this.dataForm.feuipmentid) {
          this.dataForm = this.listTmp;
          this.dataForm.details = this.actionsTmp;
          const index = this.list.indexOf(v);
          this.list.splice(index, 1, this.dataForm);
          return;
        }
      });
    },
    // 弹窗点击关闭前的回调
    handleClose(){
      this.indexs = 1;
      this.dialogFormVisible = false;
      this.list.forEach((v) => {
        if (v.feuipmentid === this.dataForm.feuipmentid) {
          this.dataForm = this.listTmp;
          this.dataForm.details = this.actionsTmp;
          const index = this.list.indexOf(v);
          this.list.splice(index, 1, this.dataForm);
          return;
        }
      });
    },

    //图片
    formdata2: function(fpointno) {
      // const formdata = new FormData()
      // formdata.append('fpointno', '123456')
        return { 'ftype': '5', 'fpointno': fpointno }
    },
    handleAvatarSuccess(res, file) {
      // this.dataForm.fimage = URL.createObjectURL(file.raw)
      this.dataForm.fimage = res.data
      const time = new Date().getTime()
      this.dataForm.fimage = `${this.dataForm.fimage}?time=${time}`
    },

    beforeAvatarUpload(file) {
      // const isJPG = file.type === 'image/jpeg'
      const isLt2M = file.size / 1024 / 1024 < 2

      // if (!isJPG) {
      //   this.$message.error('上传头像图片只能是 JPG 格式!')
      // }
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 2MB!')
      }
      return isLt2M // isJPG &&
    },

    //*图片

  },
};
</script>
